package com.mobisystems.youpark;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import android.os.Build;

import com.facebook.widget.UserSettingsFragment;
import com.parse.ParseInstallation;
import com.parse.ParseQuery;

public class RequestActivity extends Activity {

	private TextView tvUsersNotificationSent;
	private Button btnCancelRequest;
	private Button btnRaisePrice;
	private Bundle extras;

	// Storing the extras getting passed in from the other activity
	private List<String> extrasContent;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_request);

		// using custom action bar
		ActionBar customActionBar = getActionBar();
		customActionBar.setDisplayShowHomeEnabled(false);
		customActionBar.setDisplayShowTitleEnabled(false);
		LayoutInflater inflater = LayoutInflater.from(this);
		View view = inflater.inflate(R.layout.custom_actionbar, null);
		TextView titleTextView = (TextView) view.findViewById(R.id.title_text);
		titleTextView.setText("Request Made");
		view.findViewById(R.id.button_settings).setVisibility(View.INVISIBLE);
		view.findViewById(R.id.button_switch_modes).setVisibility(View.GONE);
		ImageButton backButton = (ImageButton) view.findViewById(R.id.button_back);
		backButton.setVisibility(View.VISIBLE);
		backButton.setBackgroundResource(R.drawable.back_button);
		backButton.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View view) {
				onBackPressed();
			}
		});
		customActionBar.setCustomView(view);
		customActionBar.setDisplayShowCustomEnabled(true);

		setUpListeners();

		extras = getIntent().getExtras();
		String usersReceivedRequest = null;
		String paymentAmount = null;

		if (extras != null) {
			paymentAmount = extras.getString("PaymentAmount");
			usersReceivedRequest = extras.getString("UsersReceivedRequest");
		}

		tvUsersNotificationSent.setText(usersReceivedRequest
				+ " has received your request for " + paymentAmount + "!\nNow we wait for them to accept.");

		btnCancelRequest.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent myMapIntent = new Intent(RequestActivity.this, MyMap.class);
				startActivity(myMapIntent);
				finish();
			}
		});

	}

	@Override
	public void onBackPressed() {
		Intent intent = new Intent(this, MyMap.class);
		startActivity(intent);
		finish();
	}

	private void setUpListeners() {
		tvUsersNotificationSent = (TextView) findViewById(R.id.tvCountOfUsersSentTo);
		btnCancelRequest = (Button) findViewById(R.id.btnCancelParkingRequest);
	}
}
